#include "./ThreadLauncher.h"

using namespace Core::ThreadManagement;

void ThreadLauncher::start() {
	if( (thread_handle_ == 0) && (thread_entry_point_ != 0) )
		thread_handle_ = new boost::thread( ThreadRunner( thread_entry_point_ ) );
	//TODO: else throw exception
}

ThreadLauncher::~ThreadLauncher() {
	if( thread_handle_ )
		thread_handle_->detach();
}

void ThreadLauncher::ThreadRunner::operator()() {
	try {
		thread_->run();
	} catch( boost::thread_interrupted &e ) {
		e; // robi nic :P
	}
}
